package com.ies.ieschool.client.view;

import com.google.gwt.core.client.GWT;
import com.ies.ieschool.client.dto.NavigationListGridRecordDTO;
import com.ies.ieschool.client.utility.PrayingTimeUtility;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.types.VisibilityMode;
import com.smartgwt.client.widgets.HTMLFlow;
import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
import com.smartgwt.client.widgets.layout.SectionStack;
import com.smartgwt.client.widgets.layout.SectionStackSection;
import com.smartgwt.client.widgets.layout.VLayout;

public class NavigationView extends VLayout {

	private static final int NAVIGATOR_WIDTH = 200;
	private static final int NAVIGATOR_HEIGHT = 590;

	private SectionStack sectionStack;

	public NavigationView() {
		super();

		GWT.log("init NavigationPane()...", null);

		// initialise the Section Stack
		this.addStyleName("contextArea");
		this.setWidth(NAVIGATOR_WIDTH);
		this.setHeight(NAVIGATOR_HEIGHT);
		sectionStack = new SectionStack();
		sectionStack.setWidth(NAVIGATOR_WIDTH);
		sectionStack.setVisibilityMode(VisibilityMode.MUTEX);
		sectionStack.setAnimateSections(true);
		// add the Section Stack to the Navigation Pane layout container
		this.addMember(sectionStack);
	}

	public void add(String sectionName, NavigationListGridRecordDTO[] sectionData,
			RecordClickHandler clickHandler) {
		sectionStack.addSection(new NavigationSectionView(sectionName,
				sectionData, clickHandler));
	}
	
	public void addPrayingtime() {
		String prayingTimeMenu = PrayingTimeUtility.getYalaPrayingTime();
		
		SectionStackSection stssPrayingTime = new SectionStackSection("เวลาละหมาด"); 
	    //stssPrayingTime.setExpanded(true);
	    HTMLFlow htmlfPrayingTime = new HTMLFlow();  
	    htmlfPrayingTime.setOverflow(Overflow.AUTO);  
	    htmlfPrayingTime.setPadding(30);  
	    htmlfPrayingTime.setContents(prayingTimeMenu);  
	    htmlfPrayingTime.setBackgroundColor("#ffffff");
	    stssPrayingTime.addItem(htmlfPrayingTime); 
	    
		sectionStack.addSection(stssPrayingTime);
	}

	public void expandSection(int section) {
		sectionStack.expandSection(section);
	}
}
